#!/bin/bash

# Termux 镜像源安装脚本

set -e

echo "安装依赖..."
sudo apt update
sudo apt install -y build-essential libgpgme-dev pkg-config

echo "安装 Rust 工具链..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env

echo "构建镜像服务器..."
cargo build --release

echo "生成 GPG 密钥..."
chmod +x keys/generate_keys.sh
./keys/generate_keys.sh

echo "创建仓库目录..."
mkdir -p repo
mkdir -p incoming

echo "编辑配置文件 config.toml:"
echo "1. 设置 server.domain 为您的域名"
echo "2. 设置 server.upload_secret 为安全的上传密钥"

echo "安装完成！"
echo "启动服务器: ./target/release/termux-mirror"